import axios from 'axios'
import API from '../service/API'
import { getBaseUrl } from '../service/Utils'

export default function ({ isServer, req, route, error, store }) {
    if (!store.state.domain) {
        return axios.get(getBaseUrl(isServer, req) + API.haogys.replace('{domainKey}', route.params.domain)).then(({ data }) => {
            if (!data.success) {
                error({ statusCode: 404, message: 'domain未找到' })
            } else {
                store.commit('init', {basic: data.result, main_category: route.query.main_category})
            }
        })
    }
}